package com.cdream.basic.algorithm.leetcode.findElement;

import java.util.HashMap;
import java.util.Map;

/**
 * @author cdream
 * @date 5/30/21
 */
public class Question454 {
    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
        Map<Integer, Integer> map1 = new HashMap<>();
        int count = 0;
        for (int i : nums1) {
            for (int j : nums2) {
                map1.put(i + j, map1.getOrDefault(i + j, 0));
            }
        }
        for (int i : nums3) {
            for (int j : nums4) {
                count += map1.getOrDefault(-i - j, 0);
            }
        }
        return count;
    }
}
